package com.yj.event_listener.callback;

import android.os.Build;
import android.telephony.TelephonyCallback;
import android.telephony.TelephonyManager;

import androidx.annotation.RequiresApi;

import com.yj.event_listener.util.LogUtil;

@RequiresApi(api = Build.VERSION_CODES.S)
public class PhoneCallbackListener extends TelephonyCallback implements TelephonyCallback.CallStateListener {
    @Override
    public void onCallStateChanged(int state) {
        switch (state) {
            // Device call state: No activity.
            case TelephonyManager.CALL_STATE_IDLE :
                LogUtil.d("TelephonyManager.CALL_STATE_IDLE");
                break;

            // Device call state: Off-hook. At least one call exists
            // that is dialing, active, or on hold, and no calls are ringing
            // or waiting.
            case TelephonyManager.CALL_STATE_OFFHOOK :
                    LogUtil.d("TelephonyManager.CALL_STATE_OFFHOOK");
                    break;

            // Device call state: Ringing. A new call arrived and is
            // ringing or waiting. In the latter case, another call is
            // already active.
            case TelephonyManager.CALL_STATE_RINGING :
                    LogUtil.d("TelephonyManager.CALL_STATE_RINGING");
                    break;
        }

    }
}
